package com.m.interfaceDemo;


public class WagesImpl implements Income {
    private Double income;


    public WagesImpl(Double income) {
        this.income = income;
    }

    /**
     * 工资收入，低于5000不用交税
     * @return
     */
    @Override
    public Double getTex(){
        if (this.income != null) {
            if (this.income < 5000) {
                return 0d;
            } else if (this.income < 8000) {
                return (this.income - 5000) * 0.03;
            } else if (this.income < 17000) {
                return (8000 - 5000) * 0.03 + (this.income - 8000) * 0.1;
            } else if (this.income < 30000) {
                return (8000 - 5000) * 0.03 + (17000 - 8000) * 0.1 + (this.income - 17000) * 0.2;
            } else if (this.income < 40000) {
                return (8000 - 5000) * 0.03 + (17000 - 8000) * 0.1 + (30000 - 17000) * 0.2 +
                        (this.income - 30000) * 0.25;
            } else if (this.income < 60000) {
                return (8000 - 5000) * 0.03 + (17000 - 8000) * 0.1 + (30000 - 17000) * 0.2 +
                        (40000 - 30000) * 0.25 + (this.income - 40000) * 0.3;
            } else if (this.income < 85000) {
                return (8000 - 5000) * 0.03 + (17000 - 8000) * 0.1 + (30000 - 17000) * 0.2 +
                        (40000 - 30000) * 0.25 + (60000 - 40000) * 0.3 + (this.income - 60000) * 0.35;
            } else if (this.income > 85000) {
                return (8000 - 5000) * 0.03 + (17000 - 8000) * 0.1 + (30000 - 17000) * 0.2 +
                        (40000 - 30000) * 0.25 + (60000 - 40000) * 0.3 + (85000 - 60000) * 0.35
                        + (this.income - 85000) * 0.45;
            }
        }
        return 0d;
    }

    public Double getIncome() {
        return this.income;
    }

}
